package day4.demo3_函数式接口;

import org.junit.Test;

import java.util.Comparator;
import java.util.function.Consumer;
import java.util.function.Supplier;

public class A {
    @Test
    public void m1(){
        Consumer<String> c0 = new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        };
        Consumer<String> c1 = s-> System.out.println(s);
        Consumer<String> c2 = System.out::println;
        c1.accept("hello");
    }

    @Test
    public void m2(){
        Emp emp = new Emp(23,"abc");
        Supplier<String> s = ()->emp.getName();
        Supplier<String> s1 = emp::getName;
        System.out.println(s.get());
        System.out.println(s1.get());
    }

    @Test
    public void m3(){
        Comparator<Integer> c1 = (n1,n2)-> Integer.compare(n1,n2);
        Comparator<Integer> c2 = Integer::compare;
        Comparator<Integer> c3 = Integer::compareTo;
        System.out.println(c3.compare(3, 3));

    }
}
